const express = require('express');
const router = express.Router();
const crypto = require('crypto');
const jwt = require('jsonwebtoken'); //引用jwt
const authenticator = require('../middleware/authenticator');
const axios = require('axios');

//生成一个随机盐
const salt = crypto.randomBytes(16).toString('hex');


const secretKey = 'pp7_secret_key'; //密钥

const generateToken = (userId, username) => {
    const payload = {
        userId,
        username
    };
    const token = jwt.sign(payload, secretKey, { expiresIn: '1h' });
    return token;
}


function userRouteModule(db) {


    // 用户登录
    router.post("/login", async (req, res) => {
        console.log(req.body)
        const {code} = req.body;
        const appId = 'wxb1290600736cde59'; // 替换为你的小程序 AppID
        const appSecret = 'dceee70940b6b5c99645fd5b8848f5ef'; // 替换为你的小程序 AppSecret
        res.send("ok")
    })

    return router;
}





module.exports = userRouteModule;
